package action.bkgl;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import services.bkgl.BkglServices;
import com.util.Component;
import com.PublicSystem;
import com.util.Util;
import com.syslog.SysLogServices;
/**
 * 办卡管理Action
 * @author Administrator
 *
 */
@Controller
@RequestMapping("BK.do")
public class BkglAction {
	PublicSystem sys = PublicSystem.getInstance();
	BkglServices ss = new BkglServices();
	SysLogServices log = SysLogServices.getInstance();
	/**
	 * 银行下拉框选项
	 * @param request
	 * @param response
	 * @throws Exception
	 */
	@RequestMapping(params = "method=getyinhang")
	public void getYinhang(HttpServletRequest request, HttpServletResponse response) throws Exception {
		List data = ss.getYinhang(Component.getQuest("sj", request));
		Component.print(Util.Encode(data), response);
	}	
	/**
	 * 质量类型下拉框选项
	 * @param request
	 * @param response
	 * @throws Exception
	 */
	@RequestMapping(params = "method=getBKLX")
	public void getBKLX(HttpServletRequest request, HttpServletResponse response) throws Exception {
		List data = ss.getBKLX(Component.getQuest("sj", request));
		Component.print(Util.Encode(data), response);
	}	
	/**
	 * 免费类型下拉框选项
	 * @param request
	 * @param response
	 * @throws Exception
	 */
	@RequestMapping(params = "method=getBKLX2")
	public void getBKLX2(HttpServletRequest request, HttpServletResponse response) throws Exception {
		List data = ss.getBKLX2(Component.getQuest("sj", request));
		Component.print(Util.Encode(data), response);
	}	
	/**
	 * 非免费类型下拉框选项
	 * @param request
	 * @param response
	 * @throws Exception
	 */
	@RequestMapping(params = "method=getBKLX3")
	public void getBKLX3(HttpServletRequest request, HttpServletResponse response) throws Exception {
		List data = ss.getBKLX3(Component.getQuest("sj", request));
		Component.print(Util.Encode(data), response);
	}	
	/**
	 * 查询单位登记信息
	 * @param request
	 * @param response
	 * @throws Exception
	 */
	@RequestMapping(params = "method=getunitdata")
	public void getunitdata(HttpServletRequest request, HttpServletResponse response) throws Exception {
		String aac001 = Component.getQuest("aac001", request);
		String azf644 = Component.getQuest("azf644", request);
		HashMap row = new HashMap();
		row.put("aac001", aac001);
		row.put("azf644", azf644);
		HashMap user = ss.getUnitData(row, aac001);
		Component.print(Util.Encode(user), response);
		String json = Util.Encode(user);
		String userid = Component.getSession("userid", request);
	    String rwid = Component.getSession("rwid", request);
		HashMap obj = new HashMap();
		if(null == json || "" == json) {
			obj.put("domainid", "SBK");   //分系统号，见sys_log_bm
			obj.put("log_type", "T05");   //日志类别，见sys_log_bm
			obj.put("userid", userid);    //操作人
			obj.put("rwh", rwid);	      //任务号（菜单号），取Component.getSession("rwid", request),若特殊则为空为自定义
			obj.put("content", "用户" + userid + "查询" + "社会保障卡号为" + aac001 + "补卡原因为" + azf644 + "的补卡信息");  //日志内容，自己组合拼装
			obj.put("czqd", "Q2");	      //操作渠道，见sys_log_bm
			obj.put("czrlb", "L01");      //操作人类别，见sys_log_bm
			obj.put("datain", userid);    //输入参数
			obj.put("dataout", "ERROR");  //输出参数
			log.sysLogMap(obj, request);
		} else {
			obj.put("domainid", "SBK");   //分系统号，见sys_log_bm
			obj.put("log_type", "T05");   //日志类别，见sys_log_bm
			obj.put("userid", userid);    //操作人
			obj.put("rwh", rwid);	      //任务号（菜单号），取Component.getSession("rwid", request),若特殊则为空为自定义
			obj.put("content", "用户" + userid + "查询" + "社会保障卡号为" + aac001 + "补卡原因为" + azf644 + "的补卡信息");  //日志内容，自己组合拼装
			obj.put("czqd", "Q2");	      //操作渠道，见sys_log_bm
			obj.put("czrlb", "L01");      //操作人类别，见sys_log_bm
			obj.put("datain", userid);    //输入参数
			obj.put("dataout", "SUCCESS");//输出参数
			log.sysLogMap(obj, request);
		}
	}	
	/**
	 * 查询单位登记信息
	 * @param request
	 * @param response
	 * @throws Exception
	 */
	@RequestMapping(params = "method=getunitdata2")
	public void getunitdata2(HttpServletRequest request, HttpServletResponse response) throws Exception {
		String aac001 = Component.getQuest("aac001", request);
		String azf644 = Component.getQuest("azf644", request);
		HashMap row = new HashMap();
		row.put("aac001", aac001);
		row.put("azf644", azf644);
		HashMap user = ss.getUnitData2(row, aac001);
		Component.print(Util.Encode(user), response);
		String json = Util.Encode(user);
		String userid = Component.getSession("userid", request);
	    String rwid = Component.getSession("rwid", request);
		HashMap obj = new HashMap();
		if(null == json || "" == json) {
			obj.put("domainid", "SBK");   //分系统号，见sys_log_bm
			obj.put("log_type", "T05");   //日志类别，见sys_log_bm
			obj.put("userid", userid);    //操作人
			obj.put("rwh", rwid);	      //任务号（菜单号），取Component.getSession("rwid", request),若特殊则为空为自定义
			obj.put("content", "用户" + userid + "查询" + "社会保障卡号为" + aac001 + "补卡原因为" + azf644 + "的补卡信息");  //日志内容，自己组合拼装
			obj.put("czqd", "Q2");	      //操作渠道，见sys_log_bm
			obj.put("czrlb", "L01");      //操作人类别，见sys_log_bm
			obj.put("datain", userid);    //输入参数
			obj.put("dataout", "ERROR");//输出参数
			log.sysLogMap(obj, request);
		} else {
			obj.put("domainid", "SBK");   //分系统号，见sys_log_bm
			obj.put("log_type", "T05");   //日志类别，见sys_log_bm
			obj.put("userid", userid);    //操作人
			obj.put("rwh", rwid);	      //任务号（菜单号），取Component.getSession("rwid", request),若特殊则为空为自定义
			obj.put("content", "用户" + userid + "查询" + "社会保障卡号为" + aac001 + "补卡原因为" + azf644 + "的补卡信息");  //日志内容，自己组合拼装
			obj.put("czqd", "Q2");	      //操作渠道，见sys_log_bm
			obj.put("czrlb", "L01");      //操作人类别，见sys_log_bm
			obj.put("datain", userid);    //输入参数
			obj.put("dataout", "SUCCESS");//输出参数
			log.sysLogMap(obj, request);
		}
	}	
	/**
	 * 性别下拉框选项
	 * @param request
	 * @param response
	 * @throws Exception
	 */
	@RequestMapping(params = "method=getselectxb")
	public void getSelectxb(HttpServletRequest request, HttpServletResponse response) throws Exception {
		List data = ss.getSelect(Component.getQuest("xb", request));
		Component.print(Util.Encode(data), response);
	}
	/**
	 * 民族下拉框选项
	 * @param request
	 * @param response
	 * @throws Exception
	 */
	@RequestMapping(params = "method=getselectmz")
	public void getSelectmz(HttpServletRequest request, HttpServletResponse response) throws Exception {
		List data = ss.getSelect(Component.getQuest("mz", request));
		Component.print(Util.Encode(data), response);
	}
	/**
	 * 证件下拉框选项
	 * @param request
	 * @param response
	 * @throws Exception
	 */
	@RequestMapping(params = "method=getselectzj")
	public void getSelectzj(HttpServletRequest request, HttpServletResponse response) throws Exception {
		List data = ss.getSelect(Component.getQuest("zj", request));
		Component.print(Util.Encode(data), response);
	}
	/**
	 * 区划下拉框选项
	 * @param request
	 * @param response
	 * @throws Exception
	 */
	@RequestMapping(params = "method=getSelectqh")
	public void getSelectqh(HttpServletRequest request, HttpServletResponse response) throws Exception {
		List data = ss.getSelectqh();
		Component.print(Util.Encode(data), response);
	}
	/**
	 * 街道下拉框选项
	 * @param request
	 * @param response
	 * @throws Exception
	 */
	@RequestMapping(params = "method=checkjd")
	public void checkjd(HttpServletRequest request, HttpServletResponse response) throws Exception {
		List data = ss.getSelectjd(Component.getQuest("jd", request));
		Component.print(Util.Encode(data), response);
	}
	/**
	 * 街道下拉框选项
	 * @param request
	 * @param response
	 * @throws Exception
	 */
	@RequestMapping(params = "method=getjd")
	public void getsq(HttpServletRequest request, HttpServletResponse response) throws Exception {
		List data = ss.checkSelectjd();
		Component.print(Util.Encode(data), response);
	}
	/**
	 * 新增单位登记信息
	 * @param request
	 * @param response
	 * @throws Exception
	 */
	@RequestMapping(params = "method=saveunit")
	public void saveUnit(HttpServletRequest request, HttpServletResponse response) throws Exception {
		String idreturn = "";
		String json = request.getParameter("data");
		String aae011 = Component.getSession("userid", request);
		ArrayList rows = (ArrayList)Util.Decode(json);		
		HashMap row = (HashMap)rows.get(0);	
		String aac001 = (String) row.get("aac001");
		String azf644 = (String) row.get("azf644");
		Map m =new HashMap();
     	String sss = sys.callFunction("ZJ_GET_EVENTID", m);
     	String[] s = sss.split("&");
     	String aaz002 = s[0];
    	row.put("aaz002", aaz002);
    	row.put("aae011", aae011);	
		idreturn=ss.insertUnit(row);		
	    Component.print(idreturn, response);
	    String userid = Component.getSession("userid", request);
	    String rwid = Component.getSession("rwid", request);
		HashMap obj=new HashMap();
		obj.put("domainid", "SBK");   //分系统号，见sys_log_bm
		obj.put("log_type", "T02");   //日志类别，见sys_log_bm
		obj.put("userid", userid);    //操作人
		obj.put("rwh", rwid);	      //任务号（菜单号），取Component.getSession("rwid", request),若特殊则为空为自定义
		obj.put("content", "用户" + userid + "新增" + "社会保障卡号为" + aac001 + "补卡原因为" + azf644 + "的补卡信息");  //日志内容，自己组合拼装
		obj.put("czqd", "Q2");	      //操作渠道，见sys_log_bm
		obj.put("czrlb", "L01");      //操作人类别，见sys_log_bm
		obj.put("datain", userid);    //输入参数
		obj.put("dataout", "用户" + userid + "新增" + "社会保障卡号为" + aac001 + "补卡原因为" + azf644 + "的补卡信息");//输出参数
		log.sysLogMap(obj, request);
	} 
	/**
	 * 新增单位登记信息
	 * @param request
	 * @param response
	 * @throws Exception
	 */
	@RequestMapping(params = "method=saveunit2")
	public void saveUnit2(HttpServletRequest request, HttpServletResponse response) throws Exception {
		String idreturn = "";
		String json = request.getParameter("data");
		String aae011 = Component.getSession("userid", request);
		ArrayList rows = (ArrayList)Util.Decode(json);		
		HashMap row = (HashMap)rows.get(0);	
		Map m = new HashMap();
     	String sss = sys.callFunction("ZJ_GET_EVENTID", m);
     	String[] s = sss.split("&");
     	String aaz002 = s[0];
    	row.put("aaz002", aaz002);
    	row.put("aae011", aae011);	
		idreturn = ss.insertUnit2(row);		
	    Component.print(idreturn, response);
	    String aac001 = (String) row.get("aac001");
		String azf644 = (String) row.get("azf644");
	    String userid = Component.getSession("userid", request);
	    String rwid = Component.getSession("rwid", request);
		HashMap obj = new HashMap();
		obj.put("domainid", "SBK");   //分系统号，见sys_log_bm
		obj.put("log_type", "T02");   //日志类别，见sys_log_bm
		obj.put("userid", userid);    //操作人
		obj.put("rwh", rwid);	      //任务号（菜单号），取Component.getSession("rwid", request),若特殊则为空为自定义
		obj.put("content", "用户" + userid + "新增" + "社会保障卡号为" + aac001 + "补卡原因为" + azf644 + "的补卡信息");  //日志内容，自己组合拼装
		obj.put("czqd", "Q2");	      //操作渠道，见sys_log_bm
		obj.put("czrlb", "L01");      //操作人类别，见sys_log_bm
		obj.put("datain", userid);    //输入参数
		obj.put("dataout", "用户" + userid + "新增" + "社会保障卡号为" + aac001 + "补卡原因为" + azf644 + "的补卡信息");//输出参数
		log.sysLogMap(obj, request);
	} 
}